package org.example.java8string;

import java.util.StringJoiner;

/**
 * @Classname Test
 * @Description java8 Stirngjoniner 拼接字符串
 * @Date 2020/12/7 11:45 上午
 * @Created by xiangjd
 */
public class Test {
    public static void main(String[] args) {
        StringJoiner stringJoiner = new StringJoiner(",");
        stringJoiner.add("aaa");
        stringJoiner.add("bbb");
        stringJoiner.add("ccc");
        System.out.println(String.valueOf(stringJoiner));

        StringJoiner add = new StringJoiner(",").add("ddd").add("eee").add("fff");
        System.out.println(String.valueOf(add));

        StringJoiner str = new StringJoiner(",","[","]");
        str.add("aaa");
        str.add("bbb");
        str.add("ccc");
        System.out.println(String.valueOf(str));

        System.out.println(new StringJoiner(",").toString());
        System.out.println(new StringJoiner(",","[","]").toString());

        StringJoiner joiner = new StringJoiner(",", "[", "]");
        joiner.setEmptyValue("test1");
        System.out.println(String.valueOf(joiner));


        String str2 = String.join(",", "hello", "guys", "AAA");
        System.out.println(str2);



    }
}
